/** proxy 是不会递归代理的*/
/*let obj = {
  name: 'ahhh'
  , age: {
    n: 1
  }
};

let proxy = new Proxy(obj, {
  get(target, key) {
    console.log("target:", target);
    console.log("key:", key);
    // return target[key];
    //↑↓等价
    return Reflect.get(target, key)
  }
  , set(target, key, value) {
    console.log('update');
    // target[key] = value;
    //↑↓等价
    return Reflect.set(target, key, value)
  }
});

// console.log('proxy.name:',proxy.name); //ahhh

/!*proxy.age = 10; //update
console.log('obj:',obj); //{ name: 'ahhh', age: 10 }*!/

proxy.age.n = 'hello'; // TODO 并不能深层代理 //不会走set 打印update*/


/** 递归代理要自己实现*/
/*let obj = {
  name: 'ahhh'
  ,age:{
    n:1
  }
};
let handler = {
  get(target, key) {
    if (typeof target[key] === 'object') {
      return new Proxy(target[key], handler);
    }
    // return target[key];
    //↑↓等价
    return Reflect.get(target, key)
  }
  , set(target, key, value) {
    console.log('update');
    // target[key] = value;
    //↑↓等价
    return Reflect.set(target, key, value)
  }
};

let proxy = new Proxy(obj, handler /!* TODO 实现深度代理 *!/);

proxy.age.n = 'hello'; //会触发update*/

